import { post, Delete, get } from "../utlis/http.js"

export const userAdmin = {
  //添加修改菜单
  addSysMenu (param, type) {
    if (type == "添加菜单") {
      return post(`/sysMenu/add`, param)
    } else {
      return post(`/sysMenu/modify`, param)
    }
  },
  //菜单列表
  getSysMenuList (param) {
    if (param.field == undefined) {
      return post(`/sysMenu/list`, param)
    } else {
      return post(`/sysMenu/list?sort=${param.field},${param.order}`, param)
    }
  },
  //获得菜单信息
  findSysMenu (id) {
    return get(`/sysMenu/find/${id}`)
  },
  //删除菜单
  removeSysMenu (id) {
    return Delete(`sysMenu/remove/${id}`)
  },
  /*
  *用户管理
  */
  //添加修改用户
  addSysUser (param, type) {
    if (type == "添加用户") {
      return post(`/sysUser/add`, param)
    } else {
      return post(`/sysUser/modify`, param)
    }
  },
  //获取用户列表
  getSysUserList (param) {
    if (param.field) {
      return post(`/sysUser/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/sysUser/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //获取选中用户信息
  findSysUser (id) {
    return get(`/sysUser/find/${id}`)
  },
  //删除用户
  removeSysUser (id) {
    return Delete(`sysUser/remove/${id}`)
  },
  /*
  *用户组管理
  */
  //添加修改用户组
  addSysUserGroup (param, type) {
    if (type == "添加用户组") {
      return post(`/sysUserGroup/add`, param)
    } else {
      return post(`/sysUserGroup/modify`, param)
    }
  },
  //查询用户组列表
  getSysUserGroupList (param) {
    return post(`/sysUserGroup/list?page=${param.page}&size=${param.size}`, param)
  },
  //获取用户组信息
  findSysUserGroup (id) {
    return get(`/sysUserGroup/find/${id}`)
  },
  //删除用户组
  removeSysUserGroup (id) {
    return Delete(`/sysUserGroup/remove/${id}`)
  },
  //当前登录用户
  currentUser (param) {
    return get(`/sysUser/current`, param)
  },
  //获取当前角色侧边栏
  findMenusByUser (param) {
    return post(`/sysMenu/findMenusByUser`, param)
  },

  //获取报表链接
  cumLinksList (param) {
    return post(`/cumLinks/list`, param)
  },
  //退出前调用
  logout (param) {
    return post(`/sysUser/logout`, param)
  },
  //第一次进入前调用
  initLogin (param) {
    return post(`/sysUser/login`, param)
  },



}